const GlobalConfig = require('../modules/scm/storage/config');
module.exports.saveAuthInfo = async (data) => {
  console.log(`execute saveAuthInfo : ${JSON.stringify(data)}`);
  const { host, privateKey } = data.data;
  const authData  = {
    host,
    privateKey,
    tenantName: 'tencent',
    tenantId: 'FEDLYB9D23J',
  };
  // console.log('saveAuthInfo',data);
  try {
    const config = new GlobalConfig(data.workspace_id);
    await config.saveAuthInfo(authData);
  } catch (error) {
    console.log(error);
    return '系统错误';
  }
  return '保存成功';
};
module.exports.getAuthInfo = async (data) => {
  // console.log(`execute getAuthInfo : ${JSON.stringify(data)}`);
  const config = new GlobalConfig(data.workspace_id);
  return await config.getAuthInfo();
};


